package ltd.flyweight.liquibasehelper.module.zngk.dao.entity;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

@Data
@TableName(value = "sys_dict_data", autoResultMap = true)
public class ZngkSysDictDataEntity implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @TableId
    private Long id;

    private Integer sortIndex;

    private String name;

    private String value;

    private String dictionaryTypeId;

    private Integer asDefault;

    private String createBy;

    private Date createTime;

    private String updateBy;

    private Date updateTime;

    private String remark;

    private Integer available;

    @TableField(exist = false)
    private List<ZngkSysDictDataExtensionEntity> extensionList;

    public Map<String, ZngkSysDictDataExtensionEntity> getExtensionMapKeyWithDataKey() {
        return CollectionUtil.toMap(extensionList, new LinkedHashMap<>(), ZngkSysDictDataExtensionEntity::getDataKey);
    }

    public String getBizKey() {
        return "%s::%s".formatted(dictionaryTypeId, value);
    }

}
